<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org/">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>设置用户账户</title>
	<link rel="stylesheet" href="/admin/src/css/layui.css">
	<style>
		.mr10{
			display: inline-block;
		}
		.layui-form-label{
			min-width: 120px;
		}
		.layui-form-item .layui-input-inline{
			width:320px;
		}
	</style>
</head>

<body >
	<form class="layui-form " style="margin:20px auto;">
		<div class="layui-form-item">
			<label class="layui-form-label">用户id</label>
			<div class="layui-input-inline">
				<input type="text" name="id" id="id" value="{$info['id']}" disabled="disabled" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">用户余额</label>
			<div class="layui-input-inline">
				<input type="text" name="now_money" id="now_money" value="{$info['now_money']}" disabled="disabled" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">操作设置</label>
			<div class="layui-input-block">
				<input type="radio" name="update_type" value="1" title="增加" >
				<input type="radio" name="update_type" value="2" title="减少" >
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">设置金额</label>
			<div class="layui-input-inline">
				<input type="text" name="money" id="money" value="" placeholder="请输入金额" autocomplete="off" class="layui-input">
			</div>
		</div>
	  <div class="layui-form-item">
	    <div class="layui-input-block">
	      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
	    </div>
	  </div>
	</form>
	<script src="/admin/src/layui.js" ></script>
<script>

	var infoStatus = '{$infoStatus}'
    layui.use(['form','jquery','upload'], function(){
      var form = layui.form ,
		  layer = layui.layer,
          upload = layui.upload,
		  $= layui.jquery;
      if(infoStatus == 0){
		  layer.msg('获取不到对应的信息',{time:1000},function(){
		  		window.parent.frames.location.href="/admin/user/index"
		  })
	  }

      //监听表单提交
      form.on('submit(formDemo)', function(data){
		var postData = data.field;
          if(!postData['update_type']){
              layer.msg('请设置操作类型');
              return false
          }
          if(!postData['money'] || postData['money'] <= 0){
              layer.msg('请设置金额');
              return false
          }
		$.ajax({
			url: '/admin/user/update/balance',
			type: 'POST',
			data:postData,
			success : function (backData) {
			  if(backData['status'] == 200){
				  layer.msg(backData.message,{time:1200},function(){
					  window.parent.frames.location.href="/admin/user/index"
				  })
			  }else{
				  layer.msg(backData.message);
			  }
			}
		})
        return false;
      });
    });

</script>
</body>
</html>
